import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [
        AntDesignVueResolver({
          importStyle: 'less' // 如果使用主题定制需要改为 less
        })
      ]
    })
  ],
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true, // 关键配置
        modifyVars: {
          // 可选：定义主题变量（根据项目需要）
          'primary-color': '#1890ff'
        }
      }
    }
  },
  server: {
    host: '0.0.0.0',
    port: 8081,
    open: true,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8081', //代理地址
        changeOrigin: true, //可否跨域
        secure: false, // 如果是https接口，需要配置这个参数
        rewrite:(path)=>path.replace(/^\/api/,''),
        cookieDomainRewrite: {
          '*': ''
        }
      },
    },
  },
})
